﻿


$(document).ready(function () {







    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,basicWeek,basicDay'
        },
        editable: false,
        eventClick: function (calEvent, jsEvent, view) {

            $("#dialog-modal").dialog({
                height: 340,
                modal: true,
                buttons: {
                    "Save": function () {
                        $(this).dialog("close");
                        alert(calEvent.id);
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                },
                close: function () {

                }




            });

        },
        events: function (start, end, callback) {
            $.ajax({
                url: 'getevents',
                dataType: 'json',
                data: {
                    start: Math.round(start.getTime() / 1000),
                    end: Math.round(end.getTime() / 1000)
                },
                success: function (doc) {
                    var events = [];
                    $(doc).each(function () {
                        events.push({
                            id: $(this).attr('UniqueId'),
                            title: $(this).attr('Description'),
                            start: $.fullCalendar.parseDate(parseInt($(this).attr('CheckInUnixSecs'))),
                            end: $.fullCalendar.parseDate(parseInt($(this).attr('CheckOutUnixSecs'))),
                            color: $(this).attr('Color')
                        });
                    });
                    callback(events);
                }
            });
        }
    });

});